package cn.tedu.csmailproduct.controller;

import cn.tedu.csmailproduct.pojo.dto.AlbumAddNewDTO;
import cn.tedu.csmailproduct.pojo.dto.AttributeTemplateAddNewDTO;
import cn.tedu.csmailproduct.service.IAlbumService;
import cn.tedu.csmailproduct.service.IAttributeTemplateService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 处理属性模板相关请求的控制器
 *
 * @author java@qq.com
 * @version 0.0.1
 *
 */

@Api(tags = "04. 属性模板管理模块")
@Slf4j
@RestController
@RequestMapping("/attributetemplates")
public class AttributeTemplateController {

    @Autowired
    private IAttributeTemplateService AttributeTemplateService;

    public AttributeTemplateController(){
        log.debug("创建控制器对象：AttributeTemplateController");
    }

    // http://localhost:8080/add-new?name=属性模板001&description=属性模板001的简介&sort=199
    @ApiOperation("添加属性模板")
    @ApiOperationSupport(order = 100)
    @PostMapping("/add-new")
    public String addNew(AttributeTemplateAddNewDTO attributeTemplateAddNewDTO){
        log.debug("开始处理【添加属性模板】的请求，参数：{}：",attributeTemplateAddNewDTO);
        AttributeTemplateService.addNew(attributeTemplateAddNewDTO);
        log.debug("添加数据成功");
        return "添加属性模板成功！";
    }

    @ApiOperation("删除属性模板")
    @ApiOperationSupport(order = 200)
    @PostMapping("/{id:[a-z0-9]+}/delete")
    public String delete(@PathVariable String id){
        String message = "尝试删除id为【"+ id+"】的属性模板";
        log.debug(message);
        return message;
    }

}
